package com.gomore.opple.module.orderpay;

import android.content.Intent;
import android.os.Bundle;

import com.gomore.opple.R;
import com.gomore.opple.module.BaseActivity;
import com.gomore.opple.module.IntentStart;
import com.umeng.socialize.UMShareAPI;

import javax.inject.Inject;

/**
 * Created by asus on 2017/5/9.
 */
public class OrderPayActivity extends BaseActivity {
    @Inject
    OrderPayPresenter orderPayPresenter;

    private OrderPayFragment orderPayFragment;
    private String orderId;
    private String orderState;

    @Override
    protected void initalizeViewData() {
        super.initalizeViewData();
        if (getIntent() != null && getIntent().getStringExtra(IntentStart.ORDERID) != null) {
            orderId = getIntent().getStringExtra(IntentStart.ORDERID);
            orderState = getIntent().getStringExtra(IntentStart.ORDERSTATE);
        }
    }

    @Override
    protected void initalizeViews() {
        if (orderPayFragment == null) {
            orderPayFragment = OrderPayFragment.getInstance();
            Bundle bundle = new Bundle();
            bundle.putString(IntentStart.ORDERID, orderId);
            bundle.putString(IntentStart.ORDERSTATE, orderState);
            orderPayFragment.setArguments(bundle);
            replaceFragment(orderPayFragment, false, "order_pay_view");
        }
    }

    @Override
    protected void initializeDependencyInjector() {
        DaggerOrderPayComponent.builder()
                .dataRepositoryComponent(getRepositoryComponent())
                .orderPayPresenterModule((new OrderPayPresenterModule(orderPayFragment)))
                .build()
                .inject(this);
    }

    @Override
    protected int getLayoutView() {
        return R.layout.activity_order_pay;
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        UMShareAPI.get(this).onActivityResult(requestCode, resultCode, data);
    }
}
